package com.niit.service.impl;

import com.niit.dao.LoginMapper;
import com.niit.pojo.Consumer;
import com.niit.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional
public class LoginServiceImpl implements LoginService {

    @Autowired
    private LoginMapper loginMapper;
    @Override
    public int addStudent(Consumer consumer) {
        return loginMapper.addStudent(consumer);
    }


    @Override
    public boolean authenticateUser(String consumer_id, String consumer_password) {
        int count = loginMapper.authenticateUser(consumer_id, consumer_password);
        return count == 1;
    }

    public boolean isUsernameTaken(String consumer_id) {
        int count = loginMapper.isUsernameTaken(consumer_id);
        return count > 0;
    }

    @Override
    public boolean authenticateAdmin(String administrator_id, String administrator_password) {
        int count = loginMapper.authenticateAdmin(administrator_id, administrator_password);
        return count == 1;
    }
    @Override
    public boolean isConsumer(String consumer_id, String consumer_password) {
        int count = loginMapper.isConsumer(consumer_id, consumer_password);
        return count == 1;
    }

    @Override
    public boolean authenticateWindow(String window_id, String window_password) {
        int count = loginMapper.authenticateWindow(window_id, window_password);
        return count == 1;
    }


}
